package videoExercises;

import java.util.Iterator;
import java.util.TreeSet;

public class Test4 {
    public static void main(String[] args) {
        TreeSet<Integer> set = new TreeSet<>();
        set.add(5);
        set.add(4);
        set.add(8);
        set.add(2);
        set.add(9);
        set.add(5);
        System.out.println(set);
        //遍历
        for(Integer s : set ){
            System.out.println(s);
        }
        System.out.println("-------------------");
        Iterator<Integer> it = set.iterator();
        while(it.hasNext()){
            Integer next = it.next();
            System.out.println(next);
        }
        System.out.println("-------------------");

        set.forEach((Integer t)-> {
                System.out.println(t);
            }
        );
    }
}
